﻿using System;

using BizElements.Core;

namespace BizElements.BusinessLayer
{
    /// <summary>Generic interface for managing complex properties, ie. child/extension entities linked to parent entity via 1-to-1 relations. Primary key of such child is also a foreign key to parent entity.</summary>
    public interface IComplexPropertyAdapter
    {
        /// <summary>Complex property name.</summary>
        string PropertyName { get; }

        /// <summary>Gets property value, ie. child entity.</summary>
        /// <param name="parentEntity">Parent object that owns the child entity property worked by current adapter.</param>
        /// <returns>Child entity or <b>null</b> if it doesn't exist or hasn't been fetched.</returns>
        IDataObject GetChild(IBusinessObject parentEntity);

        /// <summary>Fetches child entity if it exists.</summary>
        /// <param name="parentEntity">Parent object that owns the child entity property worked by current adapter.</param>
        void FetchChild(IBusinessObject parentEntity);

        /// <summary>Creates a new adapter that is a copy of the current instance.</summary>
        /// <returns>A new object that is a copy of the current instance.</returns>
        IComplexPropertyAdapter Clone();
    }
}
